package com.xin.webviewcontent;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.xin.libhtmlcontent.tv.OnImgCallBack;
import com.xin.libhtmlcontent.web.WebViewHtmlContent;

import java.util.List;

public class WebDemo extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web_demo);
        init();
    }

    private void init() {
        String str = "<div>\n" +
                "<div>11111</div>\n" +
                "<img src=\"http://fuboapp.com//upload//image//20190930//1569852193570213.png\">\n" +
                "<div>11111</div>\n" +
                "<img src=\"http://fuboapp.com//upload//image//20190930//1569852193570213.png\">\n" +
                "<div>11111</div>\n" +
                "<img src=\"http://fuboapp.com//upload//image//20190930//1569852193570213.png\">\n" +
                "  <video controls>\n" +
                "        <source src=\"http://simpl.info/video/video/chrome.webm\" type=\"video/webm\">\n" +
                "        <source src=\"http://simpl.info/video/video/chrome.mp4\" type=\"video/mp4\">\n" +
                "      <p>This browser does not support the video element.</p>\n" +
                "    </video>\n" +
                "</div>";
        WebViewHtmlContent webViewHtmlContent = findViewById(R.id.web);
        webViewHtmlContent.setHtmlContent(str);
        webViewHtmlContent.setOnImgCallBack(new OnImgCallBack() {
            @Override
            public void onImgClick(List<String> ls, int position) {
                log("onImgClick() called with: ls = [" + ls + "], position = [" + position + "]");
            }
        });
    }

    private void log(String s) {
        System.out.println(s);
    }
}
